package com.vim.modules.sys.controller;

import com.vim.common.base.BaseController;
import com.vim.common.utils.COSClientUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * @作者 Administrator
 * @时间 2020-09-10 18:51
 * @版本 1.0
 * @说明 上传文件
 */
@RestController
@RequestMapping(value = "/upload")
public class UploadController extends BaseController{

    @RequestMapping("/img")
    public ResponseEntity<Map<String, Object>> uploadImg(MultipartFile file) throws Exception{
        String uploadImg = COSClientUtils.uploadImg(file);
        return new ResponseEntity<>(success(COSClientUtils.getImgUrl(uploadImg)), HttpStatus.OK);
    }
}
